package cn.edu.cug.cs.gtl.renders.openinventor.basics;

import cn.edu.cug.cs.gtl.apis.render.basics.Vec3f;
import com.openinventor.inventor.SbVec3f;

public class Vec3fImpl implements Vec3f {
    private SbVec3f nativeObject = null;
    public Vec3fImpl(){
        this.nativeObject = new SbVec3f();
    }

    public Vec3fImpl(SbVec3f v){
        this.nativeObject = v;
    }
    @Override
    public Object getNativeObject() {
        return nativeObject;
    }

    @Override
    public boolean attach(Object nativeObject) {
        if(nativeObject instanceof  SbVec3f){
            this.nativeObject = (SbVec3f) nativeObject;
            return true;
        }
        return false;
    }

    @Override
    public Object detach() {
        Object r = this.nativeObject;
        this.nativeObject=null;
        return r;
    }

    public static SbVec3f[] convertArray(Vec3f[] a){
        if(a==null || a.length==0 ) return null;
        SbVec3f [] b = new SbVec3f[a.length];
        for(int i=0;i<b.length;++i){
            b[i]=(SbVec3f)(a[i].getNativeObject());
        }
        return b;
    }
}
